package com.blyat.xsoft.kernel.component.security.exception.code;


import com.blyat.xsoft.kernel.exception.code.ErrorResult;

/**
 * @author syh
 * @date 2019/10/21
 **/
public enum SecurityErrorResult implements ErrorResult {

    ACCESS_DENIED("30000", "权限不足."),
    USER_NOT_EXISTS("30001", "用户名或者密码有误."),
    INVALID_USER("30002", "用户信息失效."),
    INVALID_TOKEN("30003", "Token校验失败.%s"),
    AUTH_FAILURE("30004", "鉴权失败.%s");

    String code, message;

    SecurityErrorResult(String code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public String getResult() {
        return code;
    }

    @Override
    public String getMessage(Object... args) {
        if (args == null || args.length <= 0) return this.message;

        try {
            return String.format(this.message, args);
        } catch (Exception e) {
            return this.message;
        }
    }
}
